from django.db import models
from utils.basemodel import BaseModel

# Create your models here.
class CategoryModel(BaseModel):
    cname = models.CharField(max_length=50,verbose_name="分类名称")
    parent = models.ForeignKey("self",blank=True,null=True,on_delete=models.CASCADE,related_name="childern",verbose_name="父级分类")
    ishot = models.BooleanField(default=False,verbose_name="是否热门")
    ishome = models.BooleanField(default=False,verbose_name="是否展示在首页")
    isgood = models.BooleanField(default=False,verbose_name="是否推荐")
    class Meta:
        db_table = "fgcategory"

    def __str__(self):
        return self.cname
class TeacherCateModel(BaseModel):
    tname = models.CharField(max_length=20,verbose_name="教师名称")
    job = models.CharField(max_length=20,verbose_name="职位")
    intro = models.TextField(verbose_name="简介")
    headimg = models.ImageField(upload_to="uploads",verbose_name="教师头像",null=True)
    class Meta:
        db_table = "teachercate"

    def __str__(self):
        return self.tname
class CrouseDeskModel(BaseModel):
    kname = models.CharField(max_length=20,verbose_name="课程名称")
    cates = models.ForeignKey(CategoryModel,on_delete=models.CASCADE,verbose_name="课程分类")
    teacher = models.ForeignKey(TeacherCateModel,on_delete=models.CASCADE,verbose_name="授课教师")
    cimg = models.ImageField(upload_to="uploads",verbose_name="课程封面",null=True)
    level = models.IntegerField(choices=(('1','初级等级'),('2','中级等级'),('3','高级等级')),default=1,verbose_name="等级难度")
    vedio = models.CharField(max_length=200,verbose_name="课程视频")
    price = models.DecimalField(max_digits=5,decimal_places=2,verbose_name="课程价格")
    disc = models.DecimalField(max_digits=5,decimal_places=2,verbose_name="课程打折")
    ishome = models.BooleanField(default=False,verbose_name="是否推荐")
    ishot = models.BooleanField(default=False,verbose_name="是否热门")
    read = models.IntegerField(default=0,verbose_name="阅读量")
    intro = models.CharField(max_length=255,default="暂无",verbose_name="课程简介")
    class Meta:
        db_table = "fgcourse"

    def __str__(self):
        return self.kname




